package com.example.text.ui.mall.viewmodel

import android.util.Log
import com.example.text.ui.mall.model.BannerTypes
import com.example.text.ui.mall.model.MallBanner
import com.example.text.ui.mall.model.MallGoods
import com.example.text.ui.mall.model.MallHomeRowItem
import com.example.text.ui.mall.model.MallRowTags
import com.example.text.ui.mall.model.MallRowTypes
import com.example.text.ui.mall.random.RandomPicProvider
import com.example.text.utils.GSON
import kotlin.random.Random

object MallDataProvider {


    fun makeMallHomeList(vm: MallHomeViewModel? = null): List<MallHomeRowItem> {
        val list = ArrayList<MallHomeRowItem>()

        vm?.mallBannersLiveData?.value?.apply {
            this.forEach { it.adAddr = "skl_app_home_banner" }
            if (this.isNotEmpty()) {
                list.add(MallHomeRowItem(type = MallRowTypes.BANNER, banners = this))
            }
        }
        vm?.goodsCategoryLiveData?.value?.forEach {
            if (!it.dataList().isNullOrEmpty()) {
                list.add(MallHomeRowItem(type = MallRowTypes.TITLE, title = it.name, id = it.id, tag = MallRowTags.GOODS))
                it.dataList()?.forEach { goods ->
                    list.add(MallHomeRowItem(type = MallRowTypes.GOODS, goods = goods))
                }
            }
        }
        return list
    }


}